/**
 * 
 */
package com.surelution.cppei.card

import org.apache.commons.io.IOUtils
import org.apache.http.Consts
import org.apache.http.HttpResponse
import org.apache.http.NameValuePair
import org.apache.http.client.HttpClient
import org.apache.http.client.entity.UrlEncodedFormEntity
import org.apache.http.client.methods.HttpPost
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.message.BasicNameValuePair

/**
 * @author <a href="mailto:guangzong.syu@gmail.com">guangzong</a>
 *
 */
class TradeHelper {
	

	public static void main(String[] args) {
		
		String url = "http://11.0.27.139:8080/petrosales-wechat-appserver-1.0/getTradeList_Acc.action";
		HttpPost post = new HttpPost(url);
		HttpClient client = new DefaultHttpClient();
		
		List<NameValuePair> nvps = new ArrayList<NameValuePair>();
		nvps.add(new BasicNameValuePair("key", "7/ZM+0PP9xTxMvQKPjpgYg=="));
		nvps.add(new BasicNameValuePair("userId", "19432579"));
		
		
		
		nvps.add(new BasicNameValuePair("selectTxDate", "2012-09-01|2014-09-30"));
		nvps.add(new BasicNameValuePair("beginDate", "2012-09-01"));
		nvps.add(new BasicNameValuePair("tradeStatus", "1"));
		nvps.add(new BasicNameValuePair("userType", "1"));
		nvps.add(new BasicNameValuePair("accountType", "1"));
		nvps.add(new BasicNameValuePair("endDate", "2014-09-30"));
		nvps.add(new BasicNameValuePair("tradeTypes", "100,101,102"));
		
		
		post.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
		HttpResponse response = client.execute(post);
		def entity = response.getEntity();
		InputStream is = entity.getContent();
		
		String line = ""
		IOUtils.readLines(is).each {
			line += it
			line += "\n"
		}
		println line
	}
}
